/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.atm.domain;

import java.io.Serializable;
import java.util.Date;
import javax.annotation.Generated;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
/**
 *
 * @author Abderahman
 */

@Entity
@Table(name = "ATMTransaction")
@NamedQueries({
    @NamedQuery(name = "ATMTransaction.findAll", query = "SELECT t FROM ATMTransaction t"),
    @NamedQuery(name = "ATMTransaction.findDepositAllNew", query = "SELECT t FROM ATMTransaction t WHERE t.type ='Deposit' AND t.status='New'"),
    @NamedQuery(name = "ATMTransaction.findByAccountID", query = "SELECT t FROM ATMTransaction t WHERE t.accountId = :accountId"),
    @NamedQuery(name = "ATMTransaction.findByType", query = "SELECT t FROM ATMTransaction t WHERE t.type = :type")
//    @NamedQuery(name = "ATMTransaction.findByDate", query = "SELECT t FROM ATMTransaction t WHERE t.date = :date")
   // @NamedQuery(name = "TRANSACTION.findByName", query = "SELECT c FROM TRANSACTION c WHERE c.name = :name"),
   // @NamedQuery(name = "TRANSACTION.findByEmail", query = "SELECT c FROM TRANSACTION c WHERE c.email = :email")
})
/**/
public class ATMTransaction implements Serializable {
    public static final String APPROVED = "Approved";
    public static final String NEW = "New";
    public static final String REJECTED = "Rejected";
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.TABLE)
    @Basic(optional = false)
    @Column(name = "TRANSACTION_ID")
    private Integer transactionId;


    @Column(name = "ACCOUNT_ID", nullable=false)
    @NotNull
    private Integer accountId;

    @Column(name = "AMOUNT", nullable=false)
    @NotNull
    private float amount;

    @Column(name = "TDATE")
    private String date;

    @Column(name = "TTIME")
    private String Time;

    @Column(name = "TYPE")
    private String type;

    @Column(name = "TRANSFEREDTO_ACCOUNT")
    private Integer transferToAccount;

    @Column(name = "PAYEEID")
    private Integer payeeID;

    @Column(name = "CUSTOMERID")
    private Integer customerID;

    @Column(name = "STATUS", nullable=false)
    private String status;


    public ATMTransaction() {
    }


    public ATMTransaction(Integer transactionId) {
        this.transactionId = transactionId;
    }

    @PrePersist
    private void setDefaults() {
        this.setStatus(NEW);
    }

    /**
     * @return the transactionId
     */
    public Integer getTransactionId() {
        return transactionId;
    }

    /**
     * @param transactionId the transactionId to set
     */
    public void setTransactionId(Integer transactionId) {
        this.transactionId = transactionId;
    }

    /**
     * @return the accountId
     */
    public Integer getAccountId() {
        return accountId;
    }

    /**
     * @param accountId the accountId to set
     */
    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }

    /**
     * @return the amount
     */
    public float getAmount() {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(float amount) {
        this.amount = amount;
    }

    /**
     * @return the date
     */
    public String getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(String date) {
        this.date = date;
    }

    /**
     * @return the Time
     */
    public String getTime() {
        return Time;
    }

    /**
     * @param Time the Time to set
     */
    public void setTime(String Time) {
        this.Time = Time;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }
    public void setApproved() {
        this.setStatus(APPROVED);
    }

    public void setRejected() {
        this.setStatus(REJECTED);
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @return the transferToAccount
     */
    public Integer getTransferToAccount() {
        return transferToAccount;
    }

    /**
     * @param transferToAccount the transferToAccount to set
     */
    public void setTransferToAccount(Integer transferToAccount) {
        this.transferToAccount = transferToAccount;
    }

    /**
     * @return the payeeID
     */
    public Integer getPayeeID() {
        return payeeID;
    }

    /**
     * @param payeeID the payeeID to set
     */
    public void setPayeeID(Integer payeeID) {
        this.payeeID = payeeID;
    }

    /**
     * @return the customerID
     */
    public Integer getCustomerID() {
        return customerID;
    }

    /**
     * @param customerID the customerID to set
     */
    public void setCustomerID(Integer customerID) {
        this.customerID = customerID;
    }
}